<template>
  <chart-map/>
</template>

<script lang="ts">
import {defineComponent, reactive, toRefs} from 'vue'
import ChartMap from './draw'

export default defineComponent({
  props: {
    points: {
      type: Object,// 引用类型的话,默认值要为函数返回值的形式!!! 1.String 2.Number 3.Boolean 4.Array 5.Object 6.Date 7.Function 8.Symbol
      require: true
    },
  },
  components: {
    ChartMap
  },
  setup(props) {
    const {points} = toRefs(props)
    const mapPoints = points.value
    // 定义响应式数据 data
    const state= reactive({
      points: [],
      count: [0,0,0,0]
    });
    // 定义方法
    const methods = {
      async nodeCount() {
        if (mapPoints.length > 0) {
          state.count = [0, 0, 0, 0]
          let num = mapPoints.length;
          //console.log("num:"+num)
          let i = 0;
          while (num) {
            if (i < 4) {
              state.count[i] = Math.floor(num % 10);
            } else {
              state.count.push(Math.floor(num % 10))
            }
            i++;
            num = Math.floor(num / 10)
          }
          // 倒序排序
          state.count.reverse()
        }
      },
    }

    return {  ...toRefs(state) }
  }
})
</script>


<style lang="scss" scoped>

</style>
